package com.yy.wga.mp.module.user.controller;


import com.yy.wga.common.core.dto.Result;
import com.yy.wga.mp.common.interceptor.RequestUserHolder;
import com.yy.wga.mp.module.user.response.UserSummaryResponse;
import com.yy.wga.mp.module.user.service.UserRelationService;
import com.yy.wga.user.feign.api.UserSummaryFeign;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 用户数据统计
 *
 * @author guochao
 * @since 2024-12-10 22:41:43
 */
@RestController
@RequestMapping(value = "/api/user/summary/")
public class UserSummaryController {
    /**
     * 服务对象
     */
    @Resource
    private UserSummaryFeign userSummaryFeign;
    @Resource
    private UserRelationService userRelationService;

    /**
     * 获取用户统计数据
     * @return
     */
    @GetMapping("get")
    public Result<UserSummaryResponse> get() {
        Result<com.yy.wga.user.feign.response.UserSummaryResponse> userSummaryResponseResult = userSummaryFeign.get(RequestUserHolder.getUserCache().getUserId());
        if (!userSummaryResponseResult.isSuccess()) {
            return Result.fail(userSummaryResponseResult.getMessage());
        }
        return Result.success(com.yy.wga.common.utils.mapping.BeansUtils.map(userSummaryResponseResult.getData(), UserSummaryResponse.class));
    }

}
